import json
import os

from base_config import BASE_PATH


def read_json(filename, file_path=None, abs_path=False):
    """
    读取
    :param file_path: 文件路径（绝对路径标识为True时失效）
    :param abs_path: 直接使用绝对路径标识
    :param filename: 文件名
    :return: 内容
    """
    if abs_path:
        path = filename
    else:
        if file_path:
            path = file_path + os.sep + filename
        else:
            path = BASE_PATH + os.sep + 'data' + os.sep + filename
    with open(path, "r", encoding='utf-8') as f:
        data = json.load(f)
    return data


if __name__ == '__main__':
    print(read_json(BASE_PATH + os.sep + "confige" + os.sep + "can_gnss_matrix.json", abs_path=True))
